package com.itheima.d2_Stream_Api;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Stream流对象的存储--->数组/集合 collect
 */
public class demo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("张三丰");
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张天宝");
        //1.集合
        Stream<String> stream = list.stream().filter(s -> s.startsWith("张"));
        List<String> ZhangList = stream.collect(Collectors.toList());//toSet
        System.out.println(ZhangList);

        //2.数组
        Stream<String> stream1 = list.stream().filter(s -> s.startsWith("张"));
        Object[] array = stream1.toArray();
        System.out.println(Arrays.toString(array));
    }
}
